layui.use(['form'], function () {
    const form = layui.form;

    let userCode = localStorage.getItem("loginUserCode");

    //监听提交
    form.on('submit(commit)', function (data) {
        let formData = JSON.stringify(data.field);
        let result = commonAjax(WORD_APP_URL+'/word/add?userCode=' + userCode, formData, 'post');
        if (result.code === 200) {
            layerMsgAddSuccess();
        } else if (result.code === 404) {
            layer.msg("该单词您已经添加过了", {icon: 5, time: 2000, shade: 0.4});
        } else {
            layerMsgAddFail();
        }

        return false;
    });
});